package de.ifgi;

public class Node {

	private String btName;
//	private String macAddress;
	private String rssi;
	private Point estPosition;
//	private String timestamp;
	private double estDistance;

	public Node() {
		super();
	}
	
	public Node(String btName, String rssi, Point estPosition) {
		this.btName = btName;
		this.rssi = rssi;
		this.estPosition = estPosition;
	}

	public String getBtName() {
		return btName;
	}

	public void setBtName(String btName) {
		this.btName = btName;
	}

	public String getRssi() {
		return rssi;
	}

	public void setRssi(String rssi) {
		this.rssi = rssi;
	}

	public Point getEstPosition() {
		return estPosition;
	}
	
	public void setEstPosition(Point estPosition) {
		this.estPosition = estPosition;
	}
	
	public void setEstDistance(double estDistance) {
		this.estDistance = estDistance;
	}
	
	public double getEstDistance() {
		return estDistance;
	}
	
	/**
	 * Get distance estimation between sender and receiver 
	 * from reference data.
	 * @return distance estimation in meters.
	 */
	public double getDistanceFromRssi() {
		if (Double.valueOf(rssi) <= -76)
			estDistance = 10;
		else if (Double.valueOf(rssi) >= -75 && Double.valueOf(rssi) <= -71)
			estDistance = 9;
		else if (Double.valueOf(rssi) >= -70 && Double.valueOf(rssi) <= -66)
			estDistance = 8;
		else if (Double.valueOf(rssi) >= -65 && Double.valueOf(rssi) <= -61)
			estDistance = 7;
		else if (Double.valueOf(rssi) >= -60 && Double.valueOf(rssi) <= -56)
			estDistance = 6;
		else if (Double.valueOf(rssi) >= -55 && Double.valueOf(rssi) <= -51)
			estDistance = 5;
		else if (Double.valueOf(rssi) >= -50 && Double.valueOf(rssi) <= -46)
			estDistance = 4;
		else if (Double.valueOf(rssi) >= -45 && Double.valueOf(rssi) <= -41)
			estDistance = 3;
		else if (Double.valueOf(rssi) >= -40 && Double.valueOf(rssi) <= -36)
			estDistance = 2;
		else if (Double.valueOf(rssi) >= -35)
			estDistance = 1;		
		return estDistance;
	}
	
}
